/**
 * 数组的扩展
 */
let div1 = document.getElementsByTagName("div")
console.log(div1) // HTMLCollection []

let div2 = document.getElementsByClassName("a")
console.log(div2) // HTMLCollection []

let div3 = document.querySelectorAll('.a')
console.log(div3) // NodeList []
console.log(div3 instanceof Array)

// 伪数组转化真正数组 es5 slice
let arr = Array.prototype.slice.call(div3)
console.log(arr)

function foo(){
  console.log(arguments instanceof Array)
}

foo(1,'aqie', true)

// 伪数组转化真正数组 es6 from
let arrayLike = {
  0:'es5',
  1:'es6',
  2:'es7',
  length:3
}
let arr1 = Array.from(arrayLike)
console.log(arr1, arr1 instanceof Array)

// Array of
let arr2 = Array.of(3)
let arr22 = new Array(3)
console.log(arr2, arr22)

let arr3 = Array.of(1, true, [1,2],{'a':1})
console.log(arr3)

let arr4 = [1,2,3,4,5]
// copyWithin 【从哪个位置开始,从哪个位置开始替换】
console.log(arr4.copyWithin(1,3))

// fill
let arr5 = new Array(3).fill(8)
arr4.fill('aqie',1,3)  // 下标3截止 [1,3)
console.log(arr4)
arr4.fill(0)
console.log(arr4)

// includes
let arr6 = [1,2,3,NaN]
console.log(arr6.indexOf(2))

console.log(NaN == NaN)
console.log(arr6.includes(NaN))

